﻿using LS.Api.Helper;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.Http;

namespace LS.Api.Controllers
{
    /// <summary>
    /// 接口父级
    /// </summary>
    public class APIBaseController : ApiController
    {
       /// <summary>
       /// 返回数据
       /// </summary>
       /// <param name="data"></param>
       /// <returns></returns>
        [NonAction]
        public virtual IHttpActionResult ApiJson(ApiJsonResult data)
        {
            HttpResponseMessage responsemsg = new HttpResponseMessage();
            var jsonSerializerSettings = new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),//小驼峰命名法                   
                DateFormatString = "yyyy-MM-dd HH:mm:ss"
            };
            return Json(data, jsonSerializerSettings, Encoding.GetEncoding("UTF-8"));
        }
    }
}